let ApiErrorNames = {};
ApiErrorNames['UNKNOW_ERROR'] = 'unknowError';//未知错误
ApiErrorNames['USER_NOT_EXIST'] = 'userNotExist';//用户不存在
ApiErrorNames['USER_HAS_REGISTER'] = 'userHasRegister';//用户已注册
ApiErrorNames['USER_LOGIN_ERROR'] = 'user_login_error';//账号或密码错误
ApiErrorNames['USER_PASSWORD_ERROR'] = 'user_password_error';//账号或密码错误
ApiErrorNames[404] = 404;//接口不存在
ApiErrorNames[500] = 500;//服务异常
/**
 * API 错误名称对应错误信息 
 * */
const error_Map = new Map();
error_Map.set(ApiErrorNames['UNKNOW_ERROR'],{code:-1,message:'未知错误'})
error_Map.set(ApiErrorNames['USER_NOT_EXIST'],{code:101,message:'用户不存在'})
error_Map.set(ApiErrorNames['USER_HAS_REGISTER'],{code:102,message:'用户已注册'})
error_Map.set(ApiErrorNames['USER_LOGIN_ERROR'],{code:103,message:'账号或密码错误'})
error_Map.set(ApiErrorNames['USER_PASSWORD_ERROR'],{code:104,message:'密码错误'})
error_Map.set(ApiErrorNames[404],{code:404,message:'NOT FOND'})
error_Map.set(ApiErrorNames[500],{code:500,message:'NOT'})
//根据错误名称获取错误信息


ApiErrorNames.getErrorInfo = (error_name)=>{
    let error_info;
    if(error_name){
        error_info = error_Map.get(error_name)
    }
    //如果没有对应的错误信息，默认'未知错误'

    if(!error_info){
        error_name = this.UNKNOW_ERROR;
        error_info = error_Map.get(error_name)
    }
    return error_info
}
module.exports = ApiErrorNames;